package hotel.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table
public class SalesLineItem {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int itemid;
	
	@JoinColumn
	@ManyToOne(fetch=FetchType.EAGER)
	private Sales sales;//对应的销售，多对一
	
	@Column(nullable=false)
	private int count;//入住人数
	
	@JoinColumn
	@OneToOne(fetch=FetchType.EAGER)
	private Room room;//入住房间
	
	@OneToMany(mappedBy="salesLineItem",fetch=FetchType.EAGER)
	List<ItemDescription> descriptions=new ArrayList<ItemDescription>();
	
	@Column(nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date checkin_time;//入住时间
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date checkout_time;//退房时间
	
	private double price;
	
	private String state;//状态

	public int getItemid() {
		return itemid;
	}

	public void setItemid(int itemid) {
		this.itemid = itemid;
	}

	public Sales getSales() {
		return sales;
	}

	public void setSales(Sales sales) {
		this.sales = sales;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public Room getRoom() {
		return room;
	}

	public void setRoom(Room room) {
		this.room = room;
	}

	public List<ItemDescription> getDescriptions() {
		return descriptions;
	}

	public void setDescriptions(List<ItemDescription> descriptions) {
		this.descriptions = descriptions;
	}

	public Date getCheckin_time() {
		return checkin_time;
	}

	public void setCheckin_time(Date checkin_time) {
		this.checkin_time = checkin_time;
	}

	public Date getCheckout_time() {
		return checkout_time;
	}

	public void setCheckout_time(Date checkout_time) {
		this.checkout_time = checkout_time;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}
}
